home *** CD-ROM | disk | FTP | other *** search
/ Super PC 34 / Super PC 34 (Shareware).iso / spc / UTIL / DJGPP2 / V2 / DJTST200.ZIP / tests / libclink / objs.cc < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-29  |  704 b   |  48 lines

  1. #include <stdlib.h>
  2. #include <string.h>
  3.  
  4. #include "slist.h"
  5. #include "objs.h"
  6.  
  7. Object *Object::first = 0;
  8.  
  9. Object::Object(char *Pname)
  10. {
  11.   name = new char[strlen(Pname)+1];
  12.   strcpy(name, Pname);
  13.   df = rf = lf = busy = 0;
  14.   next = first;
  15.   first = this;
  16. }
  17.  
  18. Object::~Object()
  19. {
  20.   delete name;
  21. }
  22.  
  23. ObjList::ObjList()
  24. {
  25.   objs = (Object **)malloc(10*sizeof(Object *));
  26.   max = 10;
  27.   count = 0;
  28. }
  29.  
  30. ObjList::~ObjList()
  31. {
  32.   free(objs);
  33. }
  34.  
  35. void ObjList::add(Object *o)
  36. {
  37.   int i;
  38.   for (i=0; i<count; i++)
  39.     if (objs[i] == o)
  40.     return;
  41.   if (count >= max)
  42.   {
  43.     max += 10;
  44.     objs = (Object **)realloc(objs, max * sizeof(Object *));
  45.   }
  46.   objs[count++] = o;
  47. }
  48.